﻿using System;
using System.Runtime.InteropServices;

namespace SDK {

    /// <summary>
    /// 注意：请勿直接引用该类中的接口函数！！请使用MagDevice和MagService实现功能！！
    /// </summary>
    public class GroupSDK {
        #region 结构体

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct ENUM_INFO {
            /// <summary>
            /// 相机名称
            /// </summary>
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string sName;

            /// <summary>
            /// 协议版本号
            /// </summary>
            public uint intVersion;

            /// <summary>
            /// 相机IP
            /// </summary>
            public uint intCamIp;

            /// <summary>
            /// 控制端IP
            /// </summary>
            public uint intUsrIp;

            /// <summary>
            /// 相机MAC地址
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
            public byte[] byCamMAC;

            /// <summary>
            /// 填充字符
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public byte[] byPad;

            /// <summary>
            /// 列表更新参数
            /// </summary>
            public uint intRefreshAck;

            /// <summary>
            /// 组播/单播
            /// </summary>
            public uint bIsMulticast;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct OUTPUT_PARAM {
            /// <summary>
            /// FPA宽度，必须为FPAWIDTH
            /// </summary>
            public uint intFPAWidth;

            /// <summary>
            /// FPA高度，必须为FPAHEIGHT
            /// </summary>
            public uint intFPAHeight;

            /// <summary>
            /// 输出图像宽度, 必须为4的整数倍, 且不小于FPA的宽度(FPAWIDTH)
            /// </summary>
            public uint intBMPWidth;

            /// <summary>
            /// 输出图像高度, 不小于FPA的高度(FPAHEIGHT)
            /// </summary>
            public uint intBMPHeight;

            /// <summary>
            /// 颜色条图像宽度, 必须为4的整数倍, 最小为4
            /// </summary>
            public uint intColorbarWidth;

            /// <summary>
            /// 颜色条图像高度, 最小为1
            /// </summary>
            public uint intColorbarHeight;

        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct RECT_ROI {
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
            public byte[] sROIName; // UTF8

            /// <summary>
            /// 以左下角为原点, x0必须小于x1
            /// </summary>
            public int x0;

            /// <summary>
            /// 以左下角为原点, y0必须小于y1
            /// </summary>
            public int y0;
            public int x1;
            public int y1;

            /// <summary>
            /// 发射率*100，例如90代表0.9
            /// </summary>
            public int intEmissivity;

            /// <summary>
            /// 报警温度，单位mC，报警方式为IO输出和画面上数字闪烁
            /// </summary>
            public int intAlarmTemp;

            /// <summary>
            /// 显示选项
            /// </summary>
            public int intDrawOpt;

            /// <summary>
            /// 采样周期(帧)
            /// </summary>
            public uint intSamplePeriod;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public int[] byPad;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct USER_ROI {
            public int intValidRectROI;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
            public RECT_ROI[] ROI;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct POINT {
            public int x;
            public int y;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct IRREGULAR_ROI {
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
            public byte[] sROIName; // UTF8

            /// <summary>
            /// ROI类型
            /// 0-point, 1-line, 2-rect, 3-circle, 4-ellipse, 5-polygon, 6-delta, 7-delta3
            /// </summary>
            public int intROIType;

            /// <summary>
            /// 以左下角为原点, x0必须小于x1
            /// </summary>
            public int x0;

            public int y0;

            /// <summary>
            /// 以左下角为原点, y0必须小于y1
            /// </summary>
            public int x1;

            public int y1;

            /// <summary>
            /// 发射率*100，例如90代表0.9
            /// </summary>
            public int intEmissivity;

            /// <summary>
            /// 报警温度，单位mC，报警方式为IO输出和画面上数字闪烁
            /// </summary>
            public int intAlarmTemp;

            /// <summary>
            /// 0-auto, 1-center, 2-left, 3-right, 4-top, 5-bottom
            /// </summary>
            public int intTextPos;

            /// <summary>
            /// 采样周期(帧）
            /// </summary>
            public uint intSamplePeriod;

            /// <summary>
            /// 有效控制点数量
            /// </summary>
            public uint intPtNumber;

            /// <summary>
            /// Points 用户输入控制点
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
            public POINT[] Points;

            public int dwReserved;

            /// <summary>
            /// 是否断电保存
            /// </summary>
            public int bNovolatile;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct RECT_ROI_REPORT {
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
            public byte[] sROIName; // UTF8

            /// <summary>
            /// 以左下角为原点, x0必须小于x1
            /// </summary>
            public int x0;

            public int y0;

            /// <summary>
            /// 以左下角为原点, y0必须小于y1
            /// </summary>
            public int x1;

            public int y1;

            /// <summary>
            /// 是否触发了报警
            /// </summary>
            public bool bAlarm;

            /// <summary>
            /// 单位mC
            /// </summary>
            public int intMinTemp;

            /// <summary>
            /// 单位mC
            /// </summary>
            public int intMaxTemp;

            /// <summary>
            /// 单位mC
            /// </summary>
            public int intAveTemp;

            /// <summary>
            /// 最高温位置
            /// </summary>
            public int intMaxPos;

            /// <summary>
            /// 单位mC
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public int[] intAlarmThreshold;

            /// <summary>
            /// 0-auto, 1-center, 2-left, 3-right, 4-top, 5-bottom
            /// </summary>
            public int intTextPos;

            /// <summary>
            /// ROI类型
            /// 0-point, 1-line, 2-rect, 3-circle, 4-ellipse, 5-polygon, 6-delta, 7-delta3
            /// </summary>
            public int intROIType;

            /// <summary>
            /// 所应用的发射率， 0表示未提供
            /// </summary>
            public float fEmissivity;

            public int dwReserved;

            /// <summary>
            /// 当前预置位编号，-1未知，需要3.0.6.3以上固件支持
            /// </summary>
            public int intPresetId;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct IRREGULAR_ROI_REPORTS {
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
            public IRREGULAR_ROI_REPORT[] reports;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct IRREGULAR_ROI_REPORT {
            public RECT_ROI_REPORT baseinfo;

            /// <summary>
            /// 0x00BBGGRR
            /// </summary>
            public uint intColor;

            /// <summary>
            /// 有效控制点数量
            /// </summary>
            public uint intPtNumber;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public POINT[] Points;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public int[] dwReserved;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct CAMERA_INFO {
            /// <summary>
            /// 探测器尺寸宽度
            /// </summary>
            public int intFPAWidth;

            /// <summary>
            /// 探测器尺寸高度
            /// </summary>
            public int intFPAHeight;

            /// <summary>
            /// 填充字符，无实际意义
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public int[] pad;

            /// <summary>
            /// 相机名称
            /// </summary>
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string sCamName;

            /// <summary>
            /// 类型名称
            /// </summary>
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
            public string sTypeName;

            /// <summary>
            /// 本型号的最高帧率
            /// </summary>
            public int intMaxFps;

            /// <summary>
            /// 当前实际输出帧率
            /// </summary>
            public int intCurrFps;

            /// <summary>
            /// (以HDMI, H.264或MPEG输出的)数字视频像素
            /// </summary>
            public int intVideoWidth;

            /// <summary>
            /// (以HDMI, H.264或MPEG输出的)数字视频像素
            /// </summary>
            public int intVideoHeight;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct CAMERA_INFO_EX {
            public CAMERA_INFO BaseInfo;

            /// <summary>
            /// 热像仪序列号
            /// </summary>
            public uint intCameraSN;

            /// <summary>
            /// 外壳温度，探测器温度，保留，保留
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
            public int[] intCamTemperature;

            /// <summary>
            /// 所使用的镜头名
            /// </summary>
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string charLensName;

            /// <summary>
            /// m
            /// </summary>
            public float fFocalLength;

            /// <summary>
            /// 标定黑体温度范围, mC
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public int[] intCaliBlackbodyRange;

            /// <summary>
            /// 保留
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
            public int[] dwReserved0;

            /// <summary>
            /// 帧生成时间, 64bit time_t
            /// </summary>
            public long timeCurrent;

            /// <summary>
            /// 纬度, 度，北纬为正
            /// </summary>
            public double dblLatitude;

            /// <summary>
            /// 经度, 度，东经为正
            /// </summary>
            public double dblLongitude;

            /// <summary>
            /// 高度, m
            /// </summary>
            public float fAltitude;



            /// <summary>
            /// 用户设置的调色板序号
            /// </summary>
            public float intPaletteIndex;

            /// <summary>
            /// 用户设置的温度单位。0: 摄氏度；1：华氏度
            /// </summary>
            public int intTempUnit;

            /// <summary>
            /// 用户设置的发射率
            /// </summary>
            public float fEmissivity;

            /// <summary>
            /// 用户设置的环境和反射温度
            /// </summary>
            public float fEnvTemp;

            /// <summary>
            /// 用户设置的大气透过率
            /// </summary>
            public float fTaoAtm;

            /// <summary>
            /// 用户设置的(热像仪外部的)窗口透过率
            /// </summary>
            public float fTaoFilter;

            /// <summary>
            /// 用户设置的目标距离 m
            /// </summary>
            public float fObjDist;

            /// <summary>
            /// 是否启用分段拉伸
            /// </summary>
            public bool bSubSectionEnlarge;

            /// <summary>
            /// 分段拉伸参数，t1, mC
            /// </summary>
            public int intEnlargeX1;

            /// <summary>
            /// 分段拉伸参数，t2, mC
            /// </summary>
            public int intEnlargeX2;

            /// <summary>
            /// 分段拉伸参数，gray1
            /// </summary>
            public uint byteEnlargeY1;

            /// <summary>
            /// 分段拉伸参数, gray2
            /// </summary>
            public uint byteEnlargeY2;

            /// <summary>
            /// 自动拉伸范围，C
            /// </summary>
            public uint intAutoEnlargeRange;

            /// <summary>
            /// 自动拉伸亮度微调，-100~100
            /// </summary>
            public int intBrightOffset;

            /// <summary>
            /// 自动拉伸对比度微调，-100~100
            /// </summary>
            public int intContrastOffset;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public int[] dwReserved1;

            /// <summary>
            /// 内嵌可见光相机尺寸
            /// </summary>
            public uint intEmbededVisWidth;

            /// <summary>
            /// 内嵌可见光相机尺寸
            /// </summary>
            public uint intEmbededVisHeight;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)]
            public int[] dwReserved2;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct CAMERA_REGCONTENT {
            /// <summary>
            /// 填充字符
            /// </summary>
            public int pad0;

            /// <summary>
            /// 热像仪名称
            /// </summary>
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string sName;

            /// <summary>
            /// 是否使用静态IP 0-未使用 1-使用
            /// </summary>
            public int intIsUseStaticIP;

            /// <summary>
            /// 静态IP，网络字节序
            /// </summary>
            public int intStaticIp;

            /// <summary>
            /// 静态IP的子网掩码, 网络字节序
            /// </summary>
            public int intStaticNetMask;

            /// <summary>
            /// 图像数据是否组播 0 不 1组播
            /// </summary>
            public int intIsMulticastImg;

            /// <summary>
            /// 图像组播的ip，网络字节序
            /// </summary>
            public int intMulticastIp;

            /// <summary>
            /// 填充字符
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public int[] pad1;

            /// <summary>
            /// 序列号，只读
            /// </summary>
            public int intSerianNo;

            /// <summary>
            /// 填充字符
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public int[] pad2;

            /// <summary>
            /// 静态网关
            /// </summary>
            public int intStaticGateWay;

            /// <summary>
            /// 填充字符
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public int[] pad3;

            /// <summary>
            /// 当前镜头编号
            /// </summary>
            public int intCurrLensIndex;

            /// <summary>
            /// 填充字符
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public int[] pad4;

            /// <summary>
            /// FFC帧数触发器，单位帧
            /// </summary>
            public int intFFCFrameTrigger;

            /// <summary>
            /// FFC温度触发器，单位mC
            /// </summary>
            public int intFFCTemperatureTrigger;

            /// <summary>
            /// 填充字符
            /// </summary>
            public int pad5;

            /// <summary>
            /// 多帧累加，单位帧, 1,2,4,8,16
            /// </summary>
            public int intAccResponse;

            /// <summary>
            /// 填充字符
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
            public int[] pad6;

            /// <summary>
            /// //输入Io功能, 0-FFC, 1-MGT, 2-BMP,3-自定义
            /// </summary>
            public int intInputIoFunction;

            #region 模拟视频控制，不影响PC机上看到的效果

            /// <summary>
            /// 调色板
            /// </summary>
            public COLOR_PALETTE intPaletteIndex;

            /// <summary>
            /// 是否叠加颜色条 0 不叠加 1 叠加
            /// </summary>
            public int intIsShowColorBar;

            /// <summary>
            /// 是否使用人工拉伸
            /// </summary>
            public int intIsUseManualEnlarge;

            /// <summary>
            /// 人工拉伸节点X1, 单位mC
            /// </summary>
            public int intEnlargeX1;

            /// <summary>
            /// 人工拉伸节点X2, 单位mC
            /// </summary>
            public int intEnlargeX2;

            /// <summary>
            /// 人工拉伸节点Y1, 单位为灰度，范围0~254
            /// </summary>
            public int intEnlargeY1;

            /// <summary>
            /// 人工拉伸节点Y2, 单位为灰度，范围1~255
            /// </summary>
            public int intEnlargeY2;

            /// <summary>
            /// 自动拉伸最小温度范围，单位C，人工分段灰度拉伸比自动拉伸优先，必须大于2，建议不小于5
            /// </summary>
            public int intAutoEnlargeRange;

            #endregion

            #region IO

            /// <summary>
            /// 模拟视频标记, 0-无,1-中心,2-高温,3-测温对象
            /// </summary>
            public int intAnalogPlot;

            /// <summary>
            /// IO报警温度
            /// </summary>
            public int intAlarmTemp;

            #endregion

            #region TV standard

            /// <summary>
            /// 模拟视频制式
            /// </summary>
            public TV_STANDARD intTVStandard;

            /// <summary>
            /// 是否启用心跳检测, 0 不适用 1 使用
            /// </summary>
            public int intIsCheckHeartBeat;

            /// <summary>
            /// 是否始终输出模拟视频，若否，则以太网传输图像时模拟视频关闭，以降低功耗 0 否 1 是
            /// </summary>
            public int intIsAlwaysAnalogOutput;

            /// <summary>
            /// 填充字符
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
            public int[] pad8;

            /// <summary>
            /// 模拟视频电子倍焦
            /// </summary>
            public EX EXLevel;

            /// <summary>
            /// DTXX搭档的可见光相机IP，MAGXX未定义
            /// </summary>
            public int intPartnerVisibleIp;

            /// <summary>
            /// 模拟视频DDE强度设置, 0~32
            /// </summary>
            public int intDDE;

            /// <summary>
            /// 填充字符
            /// </summary>
            public int pad9;

            /// <summary>
            /// 串口波特率
            /// </summary>
            public int intSerialBaudRate;

            /// <summary>
            /// 串口参数，格式为 (使能<<24) | (数据位<<16) | (停止位<<8) | 校验位。其中停止位 0-1, 1-1.5, 2-2，校验位0-None, 1-Odd, 2-Even, 3-Mark, 4-Space
            /// </summary>
            public int intSerialFeature;

            #endregion
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct TEMP_STATE {
            /// <summary>
            /// 保留字段
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
            public int[] pad0;

            /// <summary>
            /// 全相面最高温, mc
            /// </summary>
            public int intMaxTemp;

            /// <summary>
            /// 全相面最低温, mc
            /// </summary>
            public int intMinTemp;

            /// <summary>
            /// 全相面平均温, mc
            /// </summary>
            public int intAveTemp;

            /// <summary>
            /// 全相面标准差
            /// </summary>
            public int intStdTemp;

            /// <summary>
            /// 最高温度出现位置, y=int(intPosMax/FPAWIDTH), x=intPosMax-FPAWIDTH*y, 原点在图像左下角
            /// </summary>
            public int intPosMax;

            /// <summary>
            /// 最低温度出现位置, y=int(intPosMin/FPAWIDTH), x=intPosMin-FPAWIDTH*y, 原点在图像左下角
            /// </summary>
            public int intPosMin;

            /// <summary>
            /// 保留字段
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
            public int[] pad1;

            /// <summary>
            /// 全像面温度时域标准差, 单位mC, 包含景物温度变化和相机噪声两个部分，该数值对部分型号的高温热像仪不适用
            /// </summary>
            public int intAveNETDt;

            /// <summary>
            /// 保留字段
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
            public int[] pad2;

            /// <summary>
            /// 红外直方图
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
            public int[] intHistTemperature;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct FIX_PARAM {
            /// <summary>
            /// 目标距离, 单位m, 范围(2*fFocalLength, ∞)
            /// </summary>
            public float fDistance;

            /// <summary>
            /// 全局缺省发射率，范围(0,1]
            /// </summary>
            public float fEmissivity;

            /// <summary>
            /// 气温, 单位C
            /// </summary>
            public float fTemp;

            /// <summary>
            /// 相对湿度，范围(0~1)
            /// </summary>
            public float fRH;

            /// <summary>
            /// 能见度, 单位km, 范围(0, ∞)
            /// </summary>
            public float fVisDistance;

            /// <summary>
            /// 降雨强度, 单位mm/h, 范围(0, ∞)
            /// </summary>
            public float fRain;

            /// <summary>
            /// 降雪强度, 单位mm/h, 范围(0, ∞)
            /// </summary>
            public float fSnow;

            /// <summary>
            /// 修正参数1 镜头相机相关
            /// </summary>
            public float fExtrapara1;

            /// <summary>
            /// 修正参数2 镜头相机相关
            /// </summary>
            public float fExtrapara2;

            /// <summary>
            /// 大气透过率, 只读
            /// </summary>
            public float fTaoAtm;

            /// <summary>
            /// (热像仪外部的)窗口/滤光片透过率
            /// </summary>
            public float fTaoFilter;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct SHORT_RECT {
            public short left;

            public short top;

            public short right;

            public short bottom;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct OBJ_INFO {
            /// <summary>
            /// 目标编号
            /// </summary>
            public int intObjId;

            /// <summary>
            ///  目标类型
            /// </summary>
            public short shortObjType;

            /// <summary>
            /// 置信度0-100
            /// </summary>
            public short shortConfidence;

            /// <summary>
            /// 左下角为坐标原点
            /// </summary>
            public SHORT_RECT rectIr;

            /// <summary>
            /// 温度采样点x
            /// </summary>
            public short shortSamplePointIrX;

            /// <summary>
            /// 温度采样点y
            /// </summary>
            public short shortSamplePointIrY;

            /// <summary>
            /// 左下角为坐标原点
            /// </summary>
            public SHORT_RECT rectVis;

            /// <summary>
            /// 温度采样点x
            /// </summary>
            public short shortSamplePointVisX;

            /// <summary>
            /// 温度采样点y
            /// </summary>
            public short shortSamplePointVisY;

            /// <summary>
            /// 原始温度，经过修正，mc单位
            /// </summary>
            public int intTemperature;

            /// <summary>
            /// (仅针对TargetTypeFace)转换后的体温，mc单位
            /// </summary>
            public int intBodyTemp;

            /// <summary>
            /// 0-未触发报警
            /// </summary>
            public short intAlarmLevel;


            /// <summary>
            /// 0-未佩戴口罩, 1-佩戴口罩, -1-不能确定
            /// </summary>
            public byte bIsMasked;

            /// <summary>
            /// 当然人脸清晰度评价 0~100
            /// </summary>
            public byte quality;

            /// <summary>
            /// 保留字段
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
            public int[] reserved2;
        }
        #endregion

        #region NPU结构体

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct NPU_SRC {
            /// <summary>
            /// 选择图像源
            /// </summary>
            public NPU_IMG_SRC src;

            /// <summary>
            /// 图像源左剪裁
            /// </summary>
            public uint intCropLeft;

            public uint intCropRight;

            public uint intCropTop;

            public uint intCropBottom;

            /// <summary>
            /// （剪裁后的）缩放目标尺寸，即神经网络尺寸
            /// </summary>
            public uint intNetworkWidth;

            public uint intNetworkHeight;

            /// <summary>
            /// 输入神经网络的数据格式，目前只支持NpuImgPlanarRGB和NpuImgGray
            /// </summary>
            public NPU_IMG_PIXEL_FORMAT PixelFormat;

            /// <summary>
            /// 输入神经网络的像素顺序，目前只支持NpuImgScanTopDown
            /// </summary>
            public NPU_IMG_SCAN PixelScan;

            /// <summary>
            /// 约定的后处理算法编号, 0为客户端后处理
            /// </summary>
            public uint intPostProcessingHandle;

            /// <summary>
            /// 输入的数据格式
            /// </summary>
            public TENSOR_TYPE InputTensorType;

            /// <summary>
            /// 期望输出的数据格式
            /// </summary>
	        public TENSOR_TYPE OutputTensorType;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
            public uint[] reserved;
        }

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct TENSOR_ATTR {
            /// <summary>
            /// the dimensions array
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public uint[] dim;

            /// <summary>
            /// the number of dimensions
            /// </summary>
            public uint dimNum;

            /// <summary>
            /// fractional length for RKNN_TENSOR_QNT_DFP
            /// </summary>
            public int fl;

            /// <summary>
            /// zero point for RKNN_TENSOR_QNT_AFFINE_ASYMMETRIC
            /// </summary>
            public uint zp;

            /// <summary>
            /// scale for RKNN_TENSOR_QNT_AFFINE_ASYMMETRIC
            /// </summary>
            public float scale;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public uint[] reserved;
        };

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct TENSOR_ATTRS {
            /// <summary>
            /// 依次存放输入和输出
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public TENSOR_ATTR[] attrs;

            /// <summary>
            /// attrs数组中的输入个数
            /// </summary>
            public int inNum;

            /// <summary>
            /// attrs数组中的输出个数
            /// </summary>
            public int outNum;
        };

        #endregion

        #region 枚举

        public enum STREAM_TYPE {
            STREAM_TEMPERATURE = 2,
            STREAM_VIDEO = 4,
            STREAM_HYBRID = 6,
            STREAM_NPURESULT = 8,
            STREAM_FILE = 16
        };

        public enum COLOR_PALETTE {
            /// <summary>
            /// 白热
            /// </summary>
            GRAY1 = 0,

            /// <summary>
            /// 黑热
            /// </summary>
            GRAY2 = 1,

            /// <summary>
            /// 铁红
            /// </summary>
            IRONBOW = 2,

            /// <summary>
            /// 彩虹
            /// </summary>
            RAINBOW = 3,

            /// <summary>
            /// 琥珀
            /// </summary>
            GLOWBOW = 4,

            /// <summary>
            /// 金秋
            /// </summary>
            AUTUMN = 5,

            /// <summary>
            /// 寒冬
            /// </summary>
            WINTER = 6,

            /// <summary>
            /// 热金属
            /// </summary>
            HOTMETAL = 7,

            /// <summary>
            /// 喷射
            /// </summary>
            JET = 8,

            /// <summary>
            /// 红色饱和
            /// </summary>
            REDSATURATION = 9,
        };

        public enum TV_STANDARD {
            NTSC_M = 0,
            NTSC_J,
            PAL_BDGHI,
            PAL_M,
            PAL_NC,
        };

        public enum EX {
            E1X = 0,
            E2X,
            E4X,
        };

        public enum STANDARD_MESSAGE {
            WM_SETREDRAW = 0xB,
        };

        public enum ROI_TYPE {
            ROI_NONE = -1,
            ROI_POINT = 0,
            ROI_LINE = 1,
            ROI_RECTANGLE = 2,
            ROI_ELLIPSE = 3,
            ROI_TRIPHASE = 4,
        };

        public enum SOURCE_FORMAT {
            YV12 = 0,
            RGB_8 = 1,
            RGB_555 = 2,
            RGB_565 = 3,
            RGB_24 = 4,
        };

        public enum PTZIRCMD {
            PTZStop = 0,    //方位或预置位停止 参数为0
            PTZRight,       //方位 参数为运动速度0~63
            PTZLeft,
            PTZUp,
            PTZDown,
            PTZUpRight = 5,
            PTZUpLeft,
            PTZDownRight,
            PTZDownLeft,
            PTZSetPreset = 9,//预置位 参数为预置位编号0~255
            PTZCallPreset,
            PTZClearPreset,
            PTZSetAuxiliary = 12,//辅助开关 参数为辅助开关编号0~255
            PTZClearAuxiliary,
            PTZZoomStop = 14,//镜头停止变倍 参数为0
            PTZZoomIn,//镜头放大 参数为马达运动时间
            PTZZoomOut,//镜头缩小
            PTZFocusStop = 17,//镜头停止调焦 参数为0
            PTZFocusAuto,//镜头自动对焦 参数为0
            PTZFocusFar,//镜头看远 参数为马达运动时间
            PTZFocusNear,//镜头看近
            PTZFocusGoto,//镜头调焦绝对位置 参数为调焦位置
        };

        public enum PTZQuery {
            PTZQueryPan = 0,//查询云台上下角度
            PTZQueryTilt,//查询云台左右角度
            PTZQueryZoomPosition,//查询zoom绝对位置
            PTZQueryZoomState,//查询是否正在zoom
            PTZQueryFocusPosition,//查询focus绝对位置
            PTZQueryFocusState,//查询是否正在执行自动对焦
        };

        public enum SDStorageFileType {
            SDFileBMP = 0,
            SDFileJPG,
            SDFileDDT,
            SDFileMDT,
            SDFileMGT,
            SDFileAVI,
            SDFileMGS,
        };

        public enum FixSelection {
            FixSelectionDisabled = 0,
            FixSelectionManualReflect,
            FixSelectionSceneAverageReflect,
            FixSelectionCamerTempReflect,
        };

        #endregion

        #region NPU枚举

        public enum NPU_IMG_SRC {
            NpuImgSrcIr = 0,//以红外图像为数据源
            NpuImgSrcVis,//以可见光图像为数据源
            NpuImgSrcUser,//以用户上载的测试图像为数据源，测试图像必须为jpg格式
        }

        public enum NPU_IMG_PIXEL_FORMAT {
            NpuImgPlanarRGB = 0,//三通道RRRR...GGGG...BBBB...
            NpuImgPlanarBGR,//三通道BBBB...GGGG...RRRR...
            NpuImgPlanarYCbCr422,//三通道YYYY...CbCbCbCb...CrCrCrCr...
            NpuImgPlanarYCbCr420,//三通道YYYY...CbCb...CrCr...
            NpuImgPlanarYCrCb422,//三通道YYYY...CrCrCrCr..CbCbCbCb...
            NpuImgPlanarYCrCb420,//三通道YYYY...CrCr..CbCb...
            NpuImgGray,//单亮度通道YYYY...
            NpuImgInterlevedRGB,//RGBRGBRGB...
            NpuImgInterlevedBGR,//BGRBGRBGR...
        };

        public enum NPU_IMG_SCAN {
            NpuImgScanTopDown = 0,//从上向下扫描，第一个像素在左上角
            NpuImgScanBottomUp,//从下向上扫描，第一个像素在左下角
        };

        public enum TENSOR_TYPE {
            TensorFloat32 = 0,          // data type is float32
            TensorFloat16,              // data type is float16
            TensorInt8,                 // data type is int8
            TensorUint8,                // data type is uint8
            TensorInt16,                // data type is int16
        };
        #endregion

        #region 内置可见光枚举
        /* 地址顺序 */
        /*31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 */
        public enum VideoPixFormat {
            pixfmtUnknown = -1,
            pixFmtYUV420P = 0,   //< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
            pixFmtRGB24 = 2,     //< packed RGB 8:8:8, 24bpp, RGBRGB...
            pixFmtYUV422P = 4,   //< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
            pixFmtARGB = 25,     //< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
            pixFmtRGBA = 26,     //< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
            pixFmtABGR = 27,     //< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
            pixFmtBGRA = 28      //< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
        }
        #endregion

        #region 委托

        /// <summary>
        /// 播放回调
        /// void CALLBACK NewFrame(UINT intChannelIndex, int intCameraTemperature, DWORD dwFFCCounterdown, DWORD dwCamState, DWORD dwStreamType, void * pUserData);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="camTemp"></param>
        /// <param name="ffcCounter"></param>
        /// <param name="camState"></param>
        /// <param name="streamType"></param>
        /// <param name="userData"></param>
        public delegate void DelegateNewFrame(uint channelIndex, int camTemp, int ffcCounter, int camState, int streamType, IntPtr userData);


        /// <summary>
        /// 重连回调
        /// void (CALLBACK * MAG_RECONNECTCALLBACK)(UINT intChannelIndex, UINT intRecentHeartBeatTick, int intState, void * pUserData);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="recentHeartBeatTick"></param>
        /// <param name="state"></param>
        /// <param name="userData"></param>
        public delegate void DelegateReconnect(uint channelIndex, uint recentHeartBeatTick, int state, IntPtr userData);

        /// <summary>
        /// 串口回调
        /// void (CALLBACK * MAG_SERIALCALLBACK)(UINT intChannelIndex, void * pData, UINT intDataLength, void * pUserData);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="data"></param>
        /// <param name="length"></param>
        /// <param name="userData"></param>
        public delegate void DelegateSerial(uint channelIndex, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint length, IntPtr userData);

        /// <summary>
        /// DDT压缩回调
        /// void (CALLBACK * MAG_DDTCOMPRESSCALLBACK)(UINT intChannelIndex, void * pData, UINT intDataLength, void * pUserData);
        /// </summary>
        /// <param name="intChannelIndex"></param>
        /// <param name="data"></param>
        /// <param name="length"></param>
        /// <param name="userData"></param>
        public delegate void DelegateDDTCompressComplete(uint intChannelIndex, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint length, IntPtr userData);

        /// <summary>
        /// RECT ROI回调
        /// void (CALLBACK* MAG_ROICALLBACK)(UINT intChannelIndex, struct struct_RectROIReport * pReports, UINT intROINum, void* pUserData);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="reports"></param>
        /// <param name="num"></param>
        /// <param name="userData"></param>
        public delegate void DelegateROIReport(uint channelIndex, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] RECT_ROI_REPORT[] reports, uint num, IntPtr userData);

        /// <summary>
        /// Irregular ROI回调
        /// void (CALLBACK* MAG_IRREGULARROICALLBACK)(UINT intChannelIndex, struct struct_IrregularROIReport * pReports, UINT intROINum, void* pUserData);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="reports"></param>
        /// <param name="num"></param>
        /// <param name="userData"></param>
        public delegate void DelegateIrregularROIReport(uint channelIndex,
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IRREGULAR_ROI_REPORT[] reports, uint num, IntPtr userData);

        /// <summary>
        /// 目标检测/识别回调
        /// void (CALLBACK * MAG_OBJRECOCALLBACK)(UINT intChannelIndex, struct struct_ObjInfo * pReports, UINT intObjNum, void * pUserData);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="reports"></param>
        /// <param name="num"></param>
        /// <param name="userData"></param>
        public delegate void DelegateObjReco(uint channelIndex, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] OBJ_INFO[] reports, uint num, IntPtr userData);
        public delegate void DelegateObjRec(uint channelIndex, IntPtr reports, uint num, IntPtr userData);

        #endregion

        #region NPU委托

        /// <summary>
        /// callback function for new NPU result arrival
        /// typedef void (CALLBACK* MAG_NPUCALLBACK) (UINT intChannelIndex, UINT intFrameCounter, const void* pSrcImg, UINT intSrcImgLen,
        /// const TensorAttrs* pTensorAttrs, const void* pResult, UINT intResultLen, void* pUserData);
        /// </summary>
        /// <param name="hDevice"></param>
        /// <param name="intFrameCounter">(src为NpuImgSrcIr时)用于推理的图像帧编号</param>
        /// <param name="pSrcImg">pSrcImg和intSrcImgLen是用于推理的图像，0表示不可用</param>
        /// <param name="pTensorAttrs">pTensorAttrs是格式描述，同一个算法数据不会变化</param>
        /// <param name="pResults">pResult和intResultLen是结果集数据包</param>
        /// <param name="pUserData">pUserData是MAG_NPU_Start()设置的pUserData</param>
        public delegate void DelegateNpu(uint channelIndex, uint frameCounter, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] byte[] srcImg, uint srcImgLen, ref TENSOR_ATTRS tensorAttrs, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] byte[] results, uint resultLen, IntPtr userData);
        #endregion

        #region 内置可见光委托

        ///<summary>
        ///用于在数据流来到之前的初始化回调
        ///void (MAGCALLTYPE * MAG_INITCALLBACK)(int channel, int width, int height, void * userData);
        ///</summary>
        /// <returns></returns>
        public delegate void DelegateVisInitialize(uint hDevice, int width, int height, IntPtr pUserData);

        ///<summary>
        /// 可见光播放回调
        ///void (MAGCALLTYPE * MAG_VISFRAMECALLBACK)(int channel, const unsigned char * frameData, int width, int height, int pixFormat, void * userData);
        ///</summary>
        /// <returns></returns>
        public delegate void DelegateVisNewFrame(uint hDevice, byte[] data, int width, int height, int pixFormat, IntPtr pUserData);

        ///<summary>
        ///可见光重连回调
        ///void (MAGCALLTYPE * MAG_VISRECONNECTALLBACK)(int channel, int status, void * userData);
        ///</summary>
        /// <returns></returns>
        public delegate void DelegateVisReconnect(uint hDevice, int status, IntPtr userData);

        #endregion

        #region 接口封装

        ///<summary>
        /// 新建一个通道
        /// _stdcall BOOL MAG_NewChannel(UINT intChannelIndex);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_NewChannel", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_NewChannel(uint channelIndex);

        ///<summary>
        /// 删除一个通道
        /// _stdcall void MAG_DelChannel(UINT intChannelIndex);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_DelChannel", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_DelChannel(uint channelIndex);

        ///<summary>
        /// 判断通道是否已可用
        /// _stdcall BOOL MAG_IsChannelAvailable(UINT intChannelIndex);
        ///</summary>
        /// <param name="intChannelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_IsChannelAvailable", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_IsChannelAvailable(uint channelIndex);

        ///<summary>
        /// 通信初始化
        /// _stdcall BOOL MAG_Initialize(UINT intChannelIndex, HWND hWndMsg);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="hWnd">必须为IntPtr.Zero</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_Initialize", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_Initialize(uint channelIndex, IntPtr hWnd);

        ///<summary>
        /// 是否已经通信初始化成功
        /// _stdcall BOOL WINAPI MAG_IsInitialized(UINT intChannelIndex);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_IsInitialized", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_IsInitialized(uint channelIndex);

        ///<summary>
        /// 释放资源
        /// _stdcall BOOL MAG_Free(UINT intChannelIndex\);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_Free", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_Free(uint channelIndex);

        ///<summary>
        /// 枚举局域网中的相机
        /// _stdcall BOOL MAG_EnumCameras();
        ///</summary>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_EnumCameras", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_EnumCameras();

        ///<summary>
        /// 连接相机
        /// _stdcall BOOL MAG_LinkCamera(UINT intChannelIndex, UINT intIP, UINT intTimeoutMS);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="ip">相机IP，网络字节序</param>
        /// <param name="timeout">连接超时时间，毫秒单位</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LinkCamera", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LinkCamera(uint channelIndex, uint ip, uint timeout);

        ///<summary>
        /// 连接相机
        // _stdcall BOOL MAG_LinkCameraEx(UINT intChannelIndex, UINT intIP, USHORT shortCmdPort, USHORT shortImgPort, 
        //      const char * charCloudUser, const char * charCloudPwd, UINT intCamSN, const char * charCamUser, const char * charCamPwd, UINT intTimeoutMS);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="ip">相机或云端IP，网络字节序</param>
        /// <param name="cmdPort">相机指令端口号</param>
        /// <param name="imgPort">相机图像端口号</param>
        /// <param name="cloudUser">ThermoAny用户名</param>
        /// <param name="cloudPwd">ThermoAny用户密码</param>
        /// <param name="serialNumber">热像仪序列号</param>
        /// <param name="cameraUser">热像仪用户名</param>
        /// <param name="cameraPwd">热像仪用户密码</param>
        /// <param name="timeout">连接超时时间，毫秒单位</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LinkCameraEx", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LinkCameraEx(uint channelIndex, uint ip, ushort cmdPort, ushort imgPort, string cloudUser,
            string cloudPwd, uint serialNumber, string cameraUser, string cameraPwd, uint timeout);

        ///<summary>
        /// 与相机断开连接
        /// _stdcall void MAG_DisLinkCamera(UINT intChannelIndex);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_DisLinkCamera", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_DisLinkCamera(uint channelIndex);

        ///<summary>
        /// 是否已经连接成功
        /// _stdcall BOOL MAG_IsLinked(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_IsLinked", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_IsLinked(uint channelIndex);

        /// <summary>
        /// 是否使用了静态IP
        /// </summary>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_IsUsingStaticIp")]
        public static extern bool MAG_IsUsingStaticIp();

        ///<summary>
        /// 得到枚举到的所有相机列表
        /// _stdcall MAG_API DWORD MAG_GetTerminalList(struct_TerminalList * pList, DWORD dwBufferSize);
        /// </summary>
        /// <param name="cameras">相机列表</param>
        /// <param name="bufSize">所提供缓冲区尺寸，字节</param>
        /// <returns>返回枚举到的相机个数</returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetTerminalList", CallingConvention = CallingConvention.StdCall)]
        public static extern uint MAG_GetTerminalList(IntPtr cameras, uint bufSize);

        ///<summary>
        /// 开始传输红外数据
        /// _stdcall BOOL MAG_StartProcessImage(UINT intChannelIndex, const OutputPara * paraOut, MAG_FRAMECALLBACK funcFrame, DWORD dwStreamType, void * pUserData);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="outputParam">相机的输出参数。</param>
        /// <param name="newFrame">回调函数</param>
        /// <param name="streamType">相机的输出数据类型</param>
        /// <param name="userData">用户数据</param>
        /// <returns>返回枚举到的相机个数</returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_StartProcessImage", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_StartProcessImage(uint channelIndex, ref OUTPUT_PARAM outputParam, DelegateNewFrame newFrame, uint streamType, IntPtr userData);

        /// <summary>
        /// 停止传输红外数据
        /// _stdcall void MAG_StopProcessImage(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_StopProcessImage", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_StopProcessImage(uint channelIndex);

        /// <summary>
        /// 判断是否正在传输红外图像
        /// _stdcall bool MAG_IsProcessingImage(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_IsProcessingImage", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_IsProcessingImage(uint channelIndex);

        ///<summary>
        ///应用新的伪彩色
        ///_stdcall void MAG_SetColorPalette(UINT intChannelIndex, enum ColorPalette ColorPaletteIndex);
        ///</summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="paletteIndex">所采用的伪彩色序号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetColorPalette", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetColorPalette(uint channelIndex, COLOR_PALETTE paletteIndex);

        /// <summary>
        /// 开启自动重连功能
        /// </summary>
        /// <param name="enabled">TREU - 开启；FALSE - 关闭</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_EnableAutoReConnect", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_EnableAutoReConnect(bool enabled);

        /// <summary>
        /// 获取相机信息
        /// _stdcall void MAG_GetCamInfo(UINT intChannelIndex, struct_CamInfo * pInfo, UINT intSize);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="cameraInfo">相机信息</param>
        /// <param name="size">输入的cameraInfo字节数</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetCamInfo", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_GetCamInfo(uint channelIndex, ref CAMERA_INFO cameraInfo, int size);

        /// <summary>
        /// 获取相机额外信息
        /// _stdcall void MAG_GetCamInfoEx(UINT intChannelIndex, struct_CamInfoEx * pInfo, UINT intSize);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="cameraInfoEx">相机信息</param>
        /// <param name="size">输入的cameraInfoEx字节数</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetCamInfoEx", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_GetCamInfoEx(uint channelIndex, ref CAMERA_INFO_EX cameraInfoEx, int size);

        /// <summary>
        /// 获取远程注册表参数
        /// _stdcall BOOL MAG_ReadCameraRegContent(UINT intChannelIndex, struct_CeRegContent * pContent, 
        /// DWORD dwTimeoutMS, BOOL bReadDefaultValue);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="content">存储在相机端注册表的内容</param>
        /// <param name="timeout">超时时间，毫秒单位</param>
        /// <param name="isReadDefaultValue">是否读取出厂设置并覆盖当前设置</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_ReadCameraRegContent", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_ReadCameraRegContent(uint channelIndex, ref CAMERA_REGCONTENT content, 
            uint timeout, int isReadDefaultValue);

        /// <summary>
        /// 设置远程注册表参数
        /// MAG_API BOOL WINAPI MAG_SetCameraRegContent(UINT intChannelIndex, const struct_CeRegContent * pContent);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="content">结构体参数</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetCameraRegContent", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetCameraRegContent(uint channelIndex, ref CAMERA_REGCONTENT content);

        /// <summary>
        /// 获取本机IP
        /// _stdcall DWORD MAG_GetLocalIp();
        /// </summary>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetLocalIp")]
        public static extern uint MAG_GetLocalIp();

        /// <summary>
        /// 获取热像仪原始数据的副本
        /// MAG_API BOOL WINAPI MAG_GetFilteredRaw_copy(UINT intChannelIndex, USHORT * pRaw, UINT intBufferSize)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data">存放raw数据的缓冲区，由用户申请</param
        /// <param name="size">用户提供的缓冲区的大小</param>
        /// <returns>ushort *</returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetFilteredRaw_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetFilteredRaw_copy(uint channelIndex, ushort[] data, uint size);

        /// <summary>
        /// 获取热像仪原始数据
        /// MAG_API const USHORT * WINAPI MAG_GetFilteredRaw(UINT intChannelIndex)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns>ushort *</returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetFilteredRaw", CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr MAG_GetFilteredRaw(uint channelIndex);

        /// <summary>
        /// 传输温度码流或混合码流时，获取输出256色位图数据
        /// MAG_API BOOL WINAPI MAG_GetOutputBMPdata(UINT intChannelIndex, UCHAR const **  pData, BITMAPINFO const ** pInfo);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="data"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputBMPdata", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputBMPdata(uint channelIndex, ref IntPtr data, ref IntPtr info);

        /// <summary>
        /// 传输温度码流或混合码流时，获取输出256色颜色条数据
        /// MAG_API BOOL WINAPI MAG_GetOutputColorBardata(UINT intChannelIndex, UCHAR const ** pData, BITMAPINFO const ** pInfo);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="pData"></param>
        /// <param name="pInfo"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputColorBardata")]
        public static extern bool MAG_GetOutputColorBardata(uint channelIndex, ref IntPtr pData, ref IntPtr pInfo);

        /// <summary>
        /// 获取24位温度真彩色图像
        /// MAG_API BOOL WINAPI MAG_GetOutputBMPdataRGB24(UINT intChannelIndex, UCHAR * pRGBBuffer, UINT intBufferSize, BOOL bOrderBGR);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data">输入数据指针，缓冲区可用尺寸BMPWidth*BMPHeight*3字节，in</param>
        /// <param name="size">缓冲区，尺寸BMPWidth*BMPHeight*3字节，in</param>
        /// <param name="bOrderBGR">FALSE - RGB; TRUE - BGR</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputBMPdataRGB24", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputBMPdataRGB24(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint size, bool bOrderBGR);
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputBMPdataRGB24", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputBMPdataRGB24(uint channelIndex, IntPtr data, uint size, bool bOrderBGR);

        /// <summary>
        /// 获取24位视频真彩色图像
        /// MAG_API BOOL WINAPI MAG_GetOutputVideoDataRGB24(UINT intChannelIndex, UCHAR * pRGBBuffer, UINT intBufferSize, BOOL bOrderBGR);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="data"></param>
        /// <param name="size"></param>
        /// <param name="bOrderBGR"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputVideoDataRGB24", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputVideoDataRGB24(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint size, bool bOrderBGR);

        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputVideoDataRGB24", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputVideoDataRGB24(uint channelIndex, IntPtr data, uint size, bool bOrderBGR);

        /// <summary>
        /// 获取24位视频真彩色颜色调图像
        /// MAG_API BOOL WINAPI MAG_GetOutputColorBardataRGB24(UINT intChannelIndex, UCHAR * pRGBBuffer, UINT intBufferSize, BOOL bOrderBGR)
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="data"></param>
        /// <param name="size"></param>
        /// <param name="bOrderBGR"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputColorBardataRGB24", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputColorBardataRGB24(uint channelIndex,
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint size, bool bOrderBGR);

        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputColorBardataRGB24", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputColorBardataRGB24(uint channelIndex, IntPtr data, uint size, bool bOrderBGR);
        
        /// <summary>
        /// 传输视频码流或混合码流时，获取输出24位视频图像数据。
        /// MAG_API BOOL WINAPI MAG_GetOutputVideoData(UINT intChannelIndex, UCHAR const **  pData, BITMAPINFO const ** pInfo);
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="pData"></param>
        /// <param name="pInfo"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputVideoData")]
        public static extern bool MAG_GetOutputVideoData(uint channelIndex, ref IntPtr pData, ref IntPtr pInfo);

        /// <summary>
        /// 获取某一点的温度值
        /// MAG_API int WINAPI MAG_GetTemperatureProbe(UINT intChannelIndex, DWORD dwPosX, DWORD dwPosY, UINT intSize);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="posX"></param>
        /// <param name="posY"></param>
        /// <param name="size">平均范围，一般去1、3、5、7</param>
        /// <returns>平均温度</returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetTemperatureProbe", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_GetTemperatureProbe(uint channelIndex, uint posX, uint posY, uint size);

        /// <summary>
        /// 修正温度
        /// MAG_API int WINAPI MAG_FixTemperature(UINT intChannelIndex, int intT, float fEmissivity, DWORD dwPosX, DWORD dwPosY);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="temp">待修正温度</param>
        /// <param name="emissivity">发射率，范围(0, 1]</param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_FixTemperature", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_FixTemperature(uint channelIndex, int temp, float emissivity, uint x, uint y);

        /// <summary>
        /// 获取校正参数，应用程序退出后将不保留
        /// MAG_API void WINAPI MAG_GetFixPara(UINT intChannelIndex, struct_FixPara * pBuffer);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="para"></param>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetFixPara", CallingConvention = CallingConvention.StdCall)]
        public static extern FixSelection MAG_GetFixPara(uint channelIndex, ref FIX_PARAM para);

        /// <summary>
        /// 设置温度修正参数
        /// MAG_API float WINAPI MAG_SetFixPara(UINT intChannelIndex, const struct_FixPara * pBuffer, enum FixSelection FixOption);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="para">修正参数</param>
        /// <param name="fixSelection">修正选项</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetFixPara", CallingConvention = CallingConvention.StdCall)]
        public static extern float MAG_SetFixPara(uint channelIndex, ref FIX_PARAM para, FixSelection fixSelection);

        /// <summary>
        /// 获取当前帧统计数据
        /// MAG_API const struct_State * WINAPI MAG_GetFrameStatisticalData(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetFrameStatisticalData", CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr MAG_GetFrameStatisticalData(uint channelIndex);

        /// <summary>
        /// 获取指定线段上的温度及其统计信息。
        /// MAG_API int WINAPI MAG_GetLineTemperatureInfo2(UINT intChannelIndex, UINT x0, UINT y0, UINT x1, UINT y1, int info[5]);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="x0">FPA坐标</param>
        /// <param name="y0">FPA坐标</param>
        /// <param name="x1">FPA坐标</param>
        /// <param name="y1">FPA坐标</param>
        /// <param name="info">统计信息: min, max, ave, minPos, maxPos</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetLineTemperatureInfo2", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_GetLineTemperatureInfo2(uint channelIndex, uint x0, uint y0, uint x1, uint y1,
            [MarshalAs(UnmanagedType.LPArray, SizeConst = 5)] int[] info);

        /// <summary>
        /// 获取Rect区域温度
        /// MAG_API BOOL WINAPI MAG_GetRectTemperatureInfo(UINT intChannelIndex, UINT x0, UINT y0, UINT x1, UINT y1, int info[5]);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="x0">FPA坐标</param>
        /// <param name="y0">FPA坐标</param>
        /// <param name="x1">FPA坐标</param>
        /// <param name="y1">FPA坐标</param>
        /// <param name="info">min max ave  posMin posMax</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetRectTemperatureInfo", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetRectTemperatureInfo(uint channelIndex, uint x0, uint y0, uint x1, uint y1, 
            [MarshalAs(UnmanagedType.LPArray, SizeConst = 5)] int[] info);

        /// <summary>
        /// 获取圆形及椭圆形区域温度
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="x0">FPA坐标</param>
        /// <param name="y0">FPA坐标</param>
        /// <param name="x1">FPA坐标</param>
        /// <param name="y1">FPA坐标</param>
        /// <param name="info">min max ave  posMin posMax</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetEllipseTemperatureInfo", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetEllipseTemperatureInfo(uint channelIndex, uint x0, uint y0, uint x1, uint y1,
            [MarshalAs(UnmanagedType.LPArray, SizeConst = 5)] int[] info);

        /// <summary>
        /// 获取多边形及多边形区域温度
        /// MAG_API BOOL WINAPI MAG_GetRgnTemperatureInfo(UINT intChannelIndex, const UINT * Pos, UINT intPosNumber, int info[5]);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="pos"></param>
        /// <param name="posNum"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetRgnTemperatureInfo")]
        public static extern bool MAG_GetRgnTemperatureInfo(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray,SizeParamIndex =2)] uint[] pos, uint posNum,
            [MarshalAs(UnmanagedType.LPArray, SizeConst = 5)] int[] info);

        /// <summary>
        /// 开始录制AVI
        /// MAG_API BOOL WINAPI MAG_LocalStorageAviStart(UINT intChannelIndex, const WCHAR * charFileName, UINT intSamplePeriod);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="fileName">AVI输出文件路径</param>
        /// <param name="samplePeriod">采样周期（帧）</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LocalStorageAviStart", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LocalStorageAviStart(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPWStr)] string fileName, uint samplePeriod);

        /// <summary>
        /// 停止录制AVI
        /// MAG_API void WINAPI MAG_LocalStorageAviStop(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LocalStorageAviStop", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_LocalStorageAviStop(uint channelIndex);


        /// <summary>
        /// 开始录制MGS
        /// MAG_API BOOL WINAPI MAG_LocalStorageMgsRecord(UINT intChannelIndex, const WCHAR * charFileName, UINT intSamplePeriod);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="fileName">AVI输出文件路径</param>
        /// <param name="samplePeriod">采样周期（帧）</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LocalStorageMgsRecord", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LocalStorageMgsRecord(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPWStr)] string fileName, uint samplePeriod);

        /// <summary>
        /// 开始播放MGS
        /// MAG_API int WINAPI MAG_LocalStorageMgsPlay(UINT intChannelIndex, const WCHAR * charFileName, 
        /// MAG_FRAMECALLBACK funcFrame, void * pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="fileName">AVI输出文件路径</param>
        /// <param name="newFrame">回调函数</param>
        /// <param name="userData">用户数据</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LocalStorageMgsPlay", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_LocalStorageMgsPlay(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPWStr)] string fileName, DelegateNewFrame newFrame, IntPtr userData);

        /// <summary>
        /// 寻找/跳至MGS指定帧数
        /// MAG_API BOOL WINAPI MAG_LocalStorageMgsSeekFrame(UINT intChannelIndex, UINT intFrameIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="hFrame">帧数</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LocalStorageMgsSeekFrame", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LocalStorageMgsSeekFrame(uint channelIndex, uint hFrame);

        /// <summary>
        /// 弹出并播放最新一帧MGS
        /// MAG_API BOOL WINAPI MAG_LocalStorageMgsPopFrame(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LocalStorageMgsPopFrame", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LocalStorageMgsPopFrame(uint channelIndex);

        /// <summary>
        /// 停止录制/播放MGS
        /// MAG_API void WINAPI MAG_LocalStorageMgsStop(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LocalStorageMgsStop", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_LocalStorageMgsStop(uint channelIndex);

        /// <summary>
        /// MAG_API BOOL WINAPI MAG_SDCardStorage(UINT intChannelIndex, enum SDStorageFileType filetype, UINT para);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="filetype"></param>
        /// <param name="para"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SDCardStorage", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SDCardStorage(uint channelIndex, SDStorageFileType filetype, uint para);

        /// <summary>
        /// 设置断线重连回调
        /// MAG_API BOOL WINAPI MAG_SetReConnectCallBack(UINT intChannelIndex, MAG_RECONNECTCALLBACK pCallBack, void * pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="funcReconnect"></param>
        /// <param name="pUser"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetReConnectCallBack", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetReConnectCallBack(uint channelIndex, DelegateReconnect funcReconnect, IntPtr pUser);

        /// <summary>
        /// 复位热像仪
        /// MAG_ResetCamera(m_pDoc->m_intChannelIndex)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_ResetCamera", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_ResetCamera(uint channelIndex);

        /// <summary>
        /// 线程锁,运算线程使用该锁
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LockFrame", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_LockFrame(uint channelIndex);

        /// <summary>
        /// 线程锁,运算线程使用该锁
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_UnLockFrame", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_UnLockFrame(uint channelIndex);

        /// <summary>
        /// 由指定矩形区域内的人体额头温度估计腋下温度
        /// MAG_API int WINAPI MAG_EstimateUnderArmTempFromForeheadRect(UINT intChannelIndex, UINT x0, UINT y0, UINT x1, UINT y1);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="x0"></param>
        /// <param name="y0"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_EstimateUnderArmTempFromForeheadRect", 
            CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_EstimateUnderArmTempFromForeheadRect(uint channelIndex, uint x0, uint y0, uint x1, uint y1);

        /// <summary>
        /// 对于内嵌可见光相机的热像仪，可通过本函数转换两个相机之间的坐标
        /// MAG_API BOOL WINAPI MAG_ConvertIrCorr2VisCorr(UINT intChannelIndex, int intIrX, 
        /// int intIrY, float fDistance, int * intVisX, int * intVisY);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="irX"></param>
        /// <param name="iirY"></param>
        /// <param name="distance"></param>
        /// <param name="visX"></param>
        /// <param name="visY"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_ConvertIrCorr2VisCorr", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_ConvertIrCorr2VisCorr(uint channelIndex, int irX, int irY, float distance, ref int visX, ref int visY);

        /// <summary>
        /// 对于内嵌可见光相机的热像仪，可通过本函数转换两个相机之间的坐标
        /// MAG_API BOOL WINAPI MAG_ConvertVisCorr2IrCorr(UINT intChannelIndex, int intVisX, 
        /// int intVisY, float fDistance, int * intIrX, int * intIrY);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="visX"></param>
        /// <param name="visY"></param>
        /// <param name="distance"></param>
        /// <param name="irX"></param>
        /// <param name="irY"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_ConvertVisCorr2IrCorr", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_ConvertVisCorr2IrCorr(uint channelIndex, int visX, int visY, float distance, ref int irX, ref int irY);

        /// <summary>
        /// 保存FIR格式文件
        /// MAG_API BOOL WINAPI MAG_SaveFIR(UINT intChannelIndex, const WCHAR * charFilename);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="fileName">文件名</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SaveFIR", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SaveFIR(uint channelIndex, [MarshalAs(UnmanagedType.LPWStr)] string fileName);

        /// <summary>
        /// 未连接相机的状态下离线分析已保存的FIR格式的文件，用户应该在使用本函数之前配置好图像处理参数。
        /// MAG_API BOOL WINAPI MAG_LoadFIR(UINT intChannelIndex, OutputPara * paraOut,
        /// const WCHAR * charFilename, MAG_FRAMECALLBACK funcFrame, void * pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="param"></param>
        /// <param name="fileName"></param>
        /// <param name="newFrame"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LoadFIR", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LoadFIR(uint channelIndex, ref OUTPUT_PARAM para, 
            [MarshalAs(UnmanagedType.LPWStr)] string fileName, DelegateNewFrame newFrame, IntPtr userData);

        /// <summary>
        /// 保存位图到文件
        /// MAG_API BOOL WINAPI MAG_SaveBMP(UINT intChannelIndex, DWORD dwIndex, const WCHAR * charFilename);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="index">0 - FPA, 1 - BMP, 2 - bar</param>
        /// <param name="fileName">文件名</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SaveBMP", CharSet = CharSet.Unicode, 
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SaveBMP(uint channelIndex, uint index, [MarshalAs(UnmanagedType.LPWStr)] string fileName);

        /// <summary>
        /// 转发云台指令
        /// MAG_API BOOL WINAPI MAG_SetPTZCmd(UINT intChannelIndex, enum PTZCmd cmd, DWORD dwPara);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="cmd">云台控制命令</param>
        /// <param name="param">指令参数，对于方向类指令，本参数为云台速度(0~63)，
        ///                     对于预置位和辅助开关类指令，
        ///                     本参数为预置位编号或辅助开关编号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetPTZCmd", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetPTZCmd(uint channelIndex, PTZIRCMD cmd, uint para);

        /// <summary>
        /// 转发串口指令
        /// MAG_API BOOL WINAPI MAG_SetSerialCmd(UINT intChannelIndex, const BYTE * buffer, UINT intBufferLen);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="cmd">命令字符串</param>
        /// <param name="cmdLen">命令长度</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetSerialCmd", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetSerialCmd(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] cmd, uint cmdLen);

        /// <summary>
        /// 设置串口回调函数
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="callback"></param>
        /// <param name="userData"></param>
        /// <return></return>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetSerialCallBack", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetSerialCallBack(uint channelIndex, DelegateSerial callback, IntPtr userData);

        /// <summary>
        /// 自动对焦
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_ExecAutoFocus", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_ExecAutoFocus(uint channelIndex);

        /// <summary>
        /// 设置热像仪的OUTPUT管脚状态
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="bAlarm"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetIoAlarmState", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetIoAlarmState(uint channelIndex, bool bAlarm);

        /// <summary>
        /// 获取心跳包
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetRecentHeartBeat", CallingConvention = CallingConvention.StdCall)]
        public static extern uint MAG_GetRecentHeartBeat(uint channelIndex);

        /// <summary>
        /// 设置用户ROI到相机
        /// MAG_API BOOL WINAPI MAG_SetUserROIs(UINT intChannelIndex, const struct_UserROIs * pROI);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="roi"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetUserROIs", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetUserROIs(uint channelIndex, ref USER_ROI roi);

        /// <summary>
        /// 设置用户ROI到相机
        /// MAG_API BOOL WINAPI MAG_SetUserROIsEx(UINT intChannelIndex, const struct_RectROI * pROIs, UINT intROINum);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="rois"></param>
        /// <param name="roiNum"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetUserROIsEx", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetUserROIsEx(uint channelIndex,
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] RECT_ROI[] rois, uint roiNum);

        /// <summary>
        /// 设置用户ROI到相机端
        /// MAG_API BOOL WINAPI MAG_SetIrregularROIs(UINT intChannelIndex, const struct_IrregularROI * pROIs, UINT intROINum)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="rois"></param>
        /// <param name="roiNum"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetIrregularROIs", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetIrregularROIs(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IRREGULAR_ROI[] rois, uint roiNum);

        /// <summary>
        /// 获取ROI报告回调 返回所有矩形
        /// MAG_API BOOL WINAPI MAG_SetROIReportCallBack(UINT intChannelIndex, MAG_ROICALLBACK pCallBack, void * pUserData)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="callBack"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetROIReportCallBack", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetROIReportCallBack(uint channelIndex, DelegateROIReport callBack, IntPtr userData);

        /// <summary>
        /// 获取ROI报告回调 返回所有形状的外接矩形
        /// MAG_API BOOL WINAPI MAG_SetIrregularROIReportCallBack(UINT intChannelIndex, MAG_ROICALLBACK pCallBack, void * pUserData)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="callBack"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetIrregularROIReportCallBack", 
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetIrregularROIReportCallBack(uint channelIndex, DelegateROIReport callBack, IntPtr userData);

        /// <summary>
        /// 获取ROI报告回调
        /// MAG_API BOOL WINAPI MAG_SetIrregularROIReportExCallBack(UINT intChannelIndex, 
        /// MAG_IRREGULARROICALLBACK  pCallBack, void * pUserData)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="callBack"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetIrregularROIReportExCallBack", 
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetIrregularROIReportExCallBack(uint channelIndex, 
            DelegateIrregularROIReport callBack, IntPtr userData);

        /// <summary>
        /// 获取人脸识别回调
        /// MAG_API BOOL WINAPI MAG_SetObjRecoCallBack(UINT intChannelIndex, MAG_OBJRECOCALLBACK pCallBack, void * pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="callBack"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetObjRecoCallBack", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetObjRecoCallBack(uint channelIndex, DelegateObjReco callBack, IntPtr userData);

        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetObjRecoCallBack", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetObjRecoCallBack(uint channelIndex, DelegateObjRec callBack, IntPtr userData);

        /// <summary>
        /// 保存DDT文件
        /// BOOL MAG_SaveDDT(UINT intChannelIndex, const WCHAR * charFilename);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SaveDDT", CharSet = CharSet.Unicode, 
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SaveDDT(uint channelIndex, [MarshalAs(UnmanagedType.LPWStr)] string fileName);

        /// <summary>
        /// 保存DDT数据到缓冲区
        /// int MAG_SaveDDT2Buffer(UINT intChannelIndex, void * pBuffer, UINT intBufferSize);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="buffer"></param>
	    /// <param name="bufferSize"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SaveDDT2Buffer", CharSet = CharSet.Unicode, 
            CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_SaveDDT2Buffer(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] buffer, uint bufferSize);

        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SaveDDT2Buffer", CharSet = CharSet.Unicode, 
            CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_SaveDDT2Buffer(uint channelIndex, IntPtr buffer, uint bufferSize);

        /// <summary>
        /// 加载DDT文件
        /// BOOL MAG_LoadDDT(UINT intChannelIndex, OutputPara * paraOut, const WCHAR * charFilename, 
        /// MAG_FRAMECALLBACK funcFrame, void * pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="para"></param>
        /// <param name="fileName"></param>
        /// <param name="newFrame"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LoadDDT", CharSet = CharSet.Unicode, 
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LoadDDT(uint channelIndex, ref OUTPUT_PARAM para, 
            [MarshalAs(UnmanagedType.LPWStr)] string fileName, DelegateNewFrame newFrame, IntPtr userData);

        /// <summary>
        /// MAG_API BOOL WINAPI MAG_LoadBufferedDDT(UINT intChannelIndex, OutputPara * paraOut, 
        /// const void * pBuffer, UINT intBufferSize, MAG_FRAMECALLBACK funcFrame, void * pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="para"></param>
        /// <param name="buffer"></param>
        /// <param name="bufferSize"></param>
        /// <param name="newFrame"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LoadBufferedDDT", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_LoadBufferedDDT(uint channelIndex, ref OUTPUT_PARAM para, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] byte[] buffer, uint bufferSize, 
            DelegateNewFrame newFrame, IntPtr userData);

        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_LoadBufferedDDT")]
        public static extern bool MAG_LoadBufferedDDT(uint hDevice, ref OUTPUT_PARAM param, IntPtr pBuffer, uint intBufferSize, 
            DelegateNewFrame newFrame, IntPtr pUserData);

        /// <summary>
        /// MAG_API int WINAPI MAG_CompressDDT(void * pDstBuffer, UINT intDstBufferSize, 
        /// const void * pSrcBuffer, UINT intSrcBufferSize, UINT intQuality);
        /// </summary>
        /// <param name="dstBuffer"></param>
        /// <param name="dstBufferSize"></param>
        /// <param name="srcBuffer"></param>
        /// <param name="srcBufferSize"></param>
        /// <param name="quality"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_CompressDDT", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_CompressDDT([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] dstBuffer, 
            uint dstBufferSize, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] byte[] srcBuffer, uint srcBufferSize, uint quality);
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_CompressDDT", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_CompressDDT(IntPtr dstBuffer, uint dstBufferSize, IntPtr srcBuffer, uint srcBufferSize, uint quality);

        /// <summary>
        /// MAG_API int WINAPI MAG_DeCompressDDT(void * pDstBuffer, UINT intDstBufferSize, const void * pSrcBuffer, UINT intSrcBufferSize);
        /// </summary>
        /// <param name="pDstBuffer"></param>
        /// <param name="intDstBufferSize"></param>
        /// <param name="pSrcBuffer"></param>
        /// <param name="intSrcBufferSize"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_DeCompressDDT", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_DeCompressDDT([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] dstBuffer, 
            uint dstBufferSize, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] byte[] srcBuffer, uint srcBufferSize);
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_DeCompressDDT", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_DeCompressDDT(IntPtr dstBuffer, uint dstBufferSize, IntPtr srcBuffer, uint srcBufferSize);

        /// <summary>
        /// 触发FFC
        /// BOOL MAG_TriggerFFC(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_TriggerFFC", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_TriggerFFC(uint channelIndex);

        /// <summary>
        /// 查询云台状态
        /// BOOL MAG_QueryPTZState(UINT intChannelIndex, enum PTZQuery query, int * intValue, UINT intTimeoutMS);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="query"></param>
        /// <param name="value"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_QueryPTZState", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_QueryPTZState(uint channelIndex, PTZQuery query, ref int value, uint timeout);

        /// <summary>
        /// 获取相机温度
        /// BOOL MAG_GetCameraTemperature(UINT intChannelIndex, int intT[4], UINT intTimeoutMS);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="t"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetCameraTemperature", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetCameraTemperature(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeConst = 4)]int[] t, uint timeout);

        /// <summary>
        /// 开始脉冲传输
        /// BOOL MAG_StartProcessPulseImage(UINT intChannelIndex, const OutputPara * paraOut, 
        /// MAG_FRAMECALLBACK funcFrame, DWORD dwStreamType, void * pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="outputParam"></param>
        /// <param name="newFrame"></param>
        /// <param name="streamtype"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_StartProcessPulseImage", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_StartProcessPulseImage(uint channelIndex, ref OUTPUT_PARAM outputParam,
            DelegateNewFrame newFrame, uint streamtype, IntPtr userData);

        /// <summary>
        /// 传输一帧数据
        /// BOOL MAG_TransferPulseImage(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_TransferPulseImage", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_TransferPulseImage(uint channelIndex);

        /// <summary>
        /// 设置人工拉伸
        /// MAG_API BOOL MAG_SetSubsectionEnlargePara(UINT intChannelIndex, int intX1, int intX2, UCHAR byteY1, UCHAR byteY2);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="x1"></param>
        /// <param name="x2"></param>
        /// <param name="y1"></param>
        /// <param name="y2"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetSubsectionEnlargePara", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetSubsectionEnlargePara(uint channelIndex, int x1, int x2, byte y1, byte y2);

        /// <summary>
        /// 设置自动拉伸
        /// void WINAPI MAG_SetAutoEnlargePara(UINT intChannelIndex, DWORD dwAutoEnlargeRange, int intBrightOffset, int intContrastOffset);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="autoEnlargeRange"></param>
        /// <param name="brightOffset"></param>
        /// <param name="contrastOffset"></param>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetAutoEnlargePara", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetAutoEnlargePara(uint channelIndex, uint autoEnlargeRange, int brightOffset, int contrastOffset);

        /// <summary>
        /// 使用自动灰度拉伸，并设置等温显示参数
        /// MAG_API void WINAPI MAG_SetIsothermalPara(UINT intChannelIndex, int intLowerLimit, int intUpperLimit);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="lowerLimit"></param>
        /// <param name="upperLimit"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetIsothermalPara", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetIsothermalPara(uint channelIndex, int lowerLimit, int upperLimit);

        /// <summary>
        /// 使用自动灰度拉伸，并设置等温显示参数
        /// MAG_API void WINAPI MAG_SetIsothermalParaEx(UINT intChannelIndex, int intLowerLimit, 
        /// int intUpperLimit, BYTE R, BYTE G, BYTE B);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="lowerLimit"></param>
        /// <param name="upperLimit"></param>
        /// <param name="r"></param>
        /// <param name="g"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetIsothermalParaEx", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetIsothermalParaEx(uint channelIndex, int lowerLimit, int upperLimit, byte r, byte g, byte b);


        /// <summary>
        /// 设置区域增强
        /// MAG_API void WINAPI MAG_SetEnhancedROI(UINT intChannelIndex, UINT intEnhancedRatio, UINT x0, UINT y0, UINT x1, UINT y1);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="enhancedRatio"></param>
        /// <param name="x0"></param>
        /// <param name="y0"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetEnhancedROI", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetEnhancedROI(uint channelIndex, uint enhancedRatio, uint x0, uint y0, uint x1, uint y1);

        /// <summary>
        /// 获取近似的灰度到温度逆转换关系
        /// MAG_API BOOL WINAPI MAG_GetApproximateGray2TemperatureLUT(UINT intChannelIndex, int * pLut, UINT intBufferSize);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="lut"></param>
        /// <param name="bufferSize"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetApproximateGray2TemperatureLUT", 
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetApproximateGray2TemperatureLUT(uint channelIndex, int[] lut, uint bufferSize);

        /// <summary>
        /// 设置电子放大倍率
        /// MAG_API void WINAPI MAG_SetEXLevel(UINT intChannelIndex, enum EX ExLevel, int intCenterX, int intCenterY);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="ex"></param>
        /// <param name="centerX"></param>
        /// <param name="centerY"></param>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetEXLevel", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetEXLevel(uint channelIndex, EX ex, int centerX, int centerY);

        /// <summary>
        /// 获取电子放大倍率
        /// MAG_API enum EX WINAPI MAG_GetEXLevel(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetEXLevel", CallingConvention = CallingConvention.StdCall)]
        public static extern EX MAG_GetEXLevel(uint channelIndex);

        /// <summary>
        /// 设置DDE强度
        /// void MAG_SetDetailEnhancement(UINT intChannelIndex, int intDDE, BOOL bQuickDDE);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="ddeLevel"></param>
        /// <param name="isQuickDDE"></param>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetDetailEnhancement", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetDetailEnhancement(uint channelIndex, int ddeLevel, int isQuickDDE);

        /// <summary>
        /// 设置对比度
        /// BOOL MAG_SetVideoContrast(UINT intChannelIndex, int intContrastOffset);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="contrastOffset"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetVideoContrast", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetVideoContrast(uint channelIndex, int contrastOffset);

        /// <summary>
        /// 设置亮度
        /// BOOL WINAPI MAG_SetVideoBrightness(UINT intChannelIndex, int intBrightnessOffset);
        /// </summary>
        /// <param name="uint channelIndex">通道号</param>
        /// <param name="brightnessOffset"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_SetVideoBrightness", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetVideoBrightness(uint channelIndex, int brightnessOffset);

        /// <summary>
        /// 获取温度数据
        ///  BOOL MAG_GetTemperatureData(UINT intChannelIndex, int * pData, UINT intBufferSize, BOOL bEnableExtCorrect);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data"></param>
        /// <param name="bufferSize"></param>
        /// <param name="isEnableExtCorrect"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetTemperatureData", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetTemperatureData(uint channelIndex, int[] data, uint bufferSize, int isEnableExtCorrect);

        /// <summary>
        /// 快速获取温度，温度精度略差
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data"></param>
        /// <param name="bufferSize"></param>
        /// <param name="isEnableExtCorrect"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetTemperatureData_Raw", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetTemperatureData_Raw(uint channelIndex, int[] data, uint bufferSize, int isEnableExtCorrect);

        /// <summary>
        /// 开启温度mask
        /// BOOL MAG_UseTemperatureMask(UINT intChannelIndex, BOOL bUse);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="isUse"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_UseTemperatureMask", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_UseTemperatureMask(uint channelIndex, int isUse);

        /// <summary>
        /// 是否使用温度mask
        /// BOOL MAG_IsUsingTemperatureMask(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_IsUsingTemperatureMask", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_IsUsingTemperatureMask(uint channelIndex);

        /// <summary>
        /// 设置数据源格式和网络结构，掉电不丢失，下次MAG_NPU_Start()生效
        /// MAG_API BOOL WINAPI MAG_NPU_SetNetwork(UINT intChannelIndex, const struct_NPUSrc* pSrcPara,
        /// const WCHAR* wcharNetworkFile, UINT intTimeoutMS);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="srcPara"></param>
        /// <param name="networkFile"></param>
        /// <param name="timeout">毫秒</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_NPU_SetNetwork", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_NPU_SetNetwork(uint channelIndex, ref NPU_SRC pSrcPara, 
            [MarshalAs(UnmanagedType.LPWStr)] string networkFile, uint timeout);

        /// <summary>
        /// 设置（分离保存的）权重文件，掉电不丢失，下次MAG_NPU_Start()生效
        /// 网络与权重合并到一个文件的，无需调用本函数
        /// MAG_API BOOL WINAPI MAG_NPU_SetWeight(UINT intChannelIndex, const WCHAR* wcharWeightFile, UINT intTimeoutMS);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="networkFile"></param>
        /// <param name="timeout">毫秒</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_NPU_SetWeight", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_NPU_SetWeight(uint channelIndex, [MarshalAs(UnmanagedType.LPWStr)] string networkFile, uint timeout);

        /// <summary>
        /// 更新一帧测试图像，掉电不丢失, 仅当选择数据源为NpuImgSrcUser时生效
        /// MAG_API BOOL WINAPI MAG_NPU_UpdateTestImage(UINT intChannelIndex, const WCHAR* wcharTestFile, UINT intTimeoutMS);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="networkFile"></param>
        /// <param name="timeout">毫秒</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_NPU_UpdateTestImage", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_NPU_UpdateTestImage(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPWStr)] string networkFile, uint timeout);

        /// <summary>
        /// 停止NPU
        /// MAG_API void WINAPI MAG_NPU_Stop(UINT intChannelIndex);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_NPU_Stop", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_NPU_Stop(uint channelIndex);

        /// <summary>
        /// 启动NPU，并设置结果集接收回调函数
        /// intInferencePriod为推理的帧间隔，0为全速计算
        /// MAG_API BOOL WINAPI MAG_NPU_Start(UINT intChannelIndex, UINT intInferencePriod, MAG_NPUCALLBACK funcNPU, void* pUserData);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="inferencePriod"></param>
        /// <param name="funcNPU"></param>
        /// <param name="userData"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_NPU_Start", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_NPU_Start(uint channelIndex, uint inferencePriod, DelegateNpu funcNPU, IntPtr userData);

        ///////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////巨哥内置可见光部分///////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// 设置可见光初始化回调函数
        /// bool MAG_SetVisInitCallback(int channel, MAG_INITCALLBACK initCallback, void * userData);
        /// </summary>
        /// <returns>小于或等于0 - 失败</returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_SetVisInitCallback", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_SetVisInitCallback(uint channelIndex, DelegateVisInitialize callback, IntPtr userData);

        /// <summary>
        /// 开始播放可见光，必须先成功连接红外热像仪。这里会注册一个回调函数，每来一帧可见光就会进一次回调函数。
        /// int MAG_StartVis(int channel, const char * rtspURL, VideoPixFormat pixelFormat, 
        /// MAG_VISFRAMECALLBACK frameCallback, void * userData, int protocol, int timeout);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="rtspUrl">rtsp地址，例如"rtsp://192.168.1.100:554/camera1"</param>
        /// <param name="pixFormat">期望输出的可见光像素格式，固定值pixFmtARGB</param>
        /// <param name="callback">新的一帧可见光数据回调函数，运行在内部新线程，与rtsp会话和rtp流接收线程是同一个线程</param>
        /// <param name="userData">回调函数参数</param>
        /// <param name="protocol">0 - UDP; 1 - TCP</param>
        /// <param name="timeout">连接超时时间</param>
        /// <returns>0 - 成功；其他 - 失败</returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_StartVis", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_StartVis(uint channelIndex, string rtspUrl, VideoPixFormat pixFormat,
                                              DelegateVisNewFrame callback, IntPtr userData, int protocol, int timeout);

        /// <summary>
        /// 获取可见光宽度
        /// int MAG_VisWidth(int channel)
        /// </summary>
        /// <returns>小于或等于0 - 失败</returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_VisWidth", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_VisWidth(uint channelIndex);

        /// <summary>
        /// 获取可见光高度
        /// int MAG_VisHeight(int channel)
        /// </summary>
        /// <returns>小于或等于0 - 失败</returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_VisHeight", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_VisHeight(uint channelIndex);

        /// <summary>
        /// 停止播放可见光
        /// void MAG_StopVis(int channel)
        /// </summary>
        /// <returns></returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_StopVis", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_StopVis(uint channelIndex);

        /// <summary>
        /// 可见光是否正在播放
        /// int MAG_IsVisStarted(int channel);
        /// </summary>
        /// <returns></returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_IsVisStarted", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_IsVisStarted(uint channelIndex);

        /// <summary>
        /// 保存当前帧可见光到文件，bitmap格式
        /// int MAG_SaveVis(int channel, const char * fileName)
        /// </summary>
        /// <returns>0 - 成功；其他 - 失败</returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_SaveVis", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_SaveVis(uint channelIndex, [MarshalAs(UnmanagedType.LPStr)] string fileName);

        /// <summary>
        /// 设置断线重连回调函数，当可见光因为网络等原因断开时的通知函数，不是必要的。
        /// void MAG_SetVisReconnectCallback(int channel, MAG_VISRECONNECTALLBACK reconnectCallback, void * userData)
        /// </summary>
        /// <returns></returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_SetVisReconnectCallback", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_SetVisReconnectCallback(uint channelIndex, DelegateVisReconnect calback, IntPtr userData);

        /// <summary>
        /// 锁住图像缓冲区，一旦返回成功，则MAG_GetVisData获取的数据将不再更新，同时长时间的锁会造成图像流接收阻塞。
        /// void MAG_LockVisFrame(int channel)
        /// </summary>
        /// <returns></returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_LockVisFrame", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_LockVisFrame(uint channelIndex);

        /// <summary>
        /// 释放图像缓冲区，与MAG_LockVisFrame配对使用
        /// void MAG_UnlockVisFrame(int channel)
        /// </summary>
        /// <returns></returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_UnlockVisFrame", CallingConvention = CallingConvention.StdCall)]
        public static extern void MAG_UnlockVisFrame(uint channelIndex);

        /// <summary>
        /// 获取最近一帧的数据，在MAG_VISFRAMECALLBACK以外的线程中获取数据需要调用MAG_LockVisFrame和MAG_UnlockVisFrame。
	    /// 否则处理数据过程中数据可能会被下一帧数据破坏。
        /// MAGAPI int MAGCALLTYPE MAG_GetVisData_copy(int channel, unsigned char * data, int size)
        /// </summary>
        /// <param name="channelIndex"></param>
        /// <param name="data"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_GetVisData_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_GetVisData_copy(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, int size);
        [DllImport("MagVisible.dll", EntryPoint = "MAG_GetVisData_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_GetVisData_copy(uint channelIndex, IntPtr data, int size);
        #endregion


        #region 已经弃用的接口，Deprecated APIs

        /// <summary>
        /// 传输温度码流或混合码流时，获取输出256色位图数据
        /// MAG_API BOOL WINAPI MAG_GetOutputBMPdata_copy(UINT intChannelIndex, UCHAR * pBmp, UINT intBufferSize);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data">图像数据</param>
        /// <param name="dataSize">输入的data大小</param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputBMPdata_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputBMPdata_copy(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint dataSize);
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputBMPdata_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputBMPdata_copy(uint channelIndex, IntPtr data, uint dataSize);

        /// <summary>
        /// 获取最近一帧的数据，数据格式为MAG_StartVis填入的pixFormat。
        /// 在MAG_VISFRAMECALLBACK以外的线程中获取数据需要调用MAG_LockVisFrame和MAG_UnlockVisFrame。
	    /// 否则处理数据过程中数据可能会被下一帧数据破坏。
        /// MAGAPI int MAGCALLTYPE MAG_GetVisData(int channel, unsigned char const ** data, void const ** info);
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data">获取到的可见裸数据</param>
        /// <param name="info">BITMAPINFO结构体数据，为windows下gdi显示所准备</param>
        /// <returns>0 - 成功；其他 - 失败</returns>
        [DllImport("MagVisible.dll", EntryPoint = "MAG_GetVisData", CallingConvention = CallingConvention.StdCall)]
        public static extern int MAG_GetVisData(uint channelIndex, ref IntPtr data, ref IntPtr info);

        /// <summary>
        /// 传输温度码流或混合码流时，获取输出256色颜色条数据
        /// MAG_API BOOL WINAPI MAG_GetOutputColorBardata_copy(UINT intChannelIndex, UCHAR * pColorBar, UINT intBufferSize)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data"></param>
        /// <param name="dataSize"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputColorBardata_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputColorBardata_copy(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint dataSize);
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputColorBardata_copy")]
        public static extern bool MAG_GetOutputColorBardata_copy(uint channelIndex, IntPtr data, uint dataSize);

        /// <summary>
        /// 传输视频码流或混合码流时，获取输出24位视频图像数据。
        /// MAG_API BOOL WINAPI MAG_GetOutputVideoData_copy(UINT intChannelIndex, UCHAR * pBmp, UINT intBufferSize)
        /// </summary>
        /// <param name="channelIndex">通道号</param>
        /// <param name="data"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputVideoData_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputVideoData_copy(uint channelIndex, 
            [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] data, uint size);

        [DllImport("ThermoGroupSDKLib.dll", EntryPoint = "MAG_GetOutputVideoData_copy", CallingConvention = CallingConvention.StdCall)]
        public static extern bool MAG_GetOutputVideoData_copy(uint channelIndex, IntPtr data, uint size);
        #endregion
    }

    #region 已经弃用的类，Deprecated APIs
    public class WINAPI {
        public enum StretchMode {
            STRETCH_ANDSCANS = 1,
            STRETCH_ORSCANS = 2,
            STRETCH_DELETESCANS = 3,
            STRETCH_HALFTONE = 4,
        }

        public enum PaletteMode {
            DIB_RGB_COLORS = 0,
            DIB_PAL_COLORS = 1
        }

        public enum ExecuteOption {
            SRCCOPY = 0x00CC0020, /* dest = source*/
            SRCPAINT = 0x00EE0086, /* dest = source OR dest*/
            SRCAND = 0x008800C6, /* dest = source AND dest*/
            SRCINVERT = 0x00660046, /* dest = source XOR dest*/
            SRCERASE = 0x00440328, /* dest = source AND (NOT dest )*/
            NOTSRCCOPY = 0x00330008, /* dest = (NOT source)*/
            NOTSRCERASE = 0x001100A6, /* dest = (NOT src) AND (NOT dest) */
            MERGECOPY = 0x00C000CA, /* dest = (source AND pattern)*/
            MERGEPAINT = 0x00BB0226, /* dest = (NOT source) OR dest*/
            PATCOPY = 0x00F00021, /* dest = pattern*/
            PATPAINT = 0x00FB0A09, /* dest = DPSnoo*/
            PATINVERT = 0x005A0049, /* dest = pattern XOR dest*/
            DSTINVERT = 0x00550009, /* dest = (NOT dest)*/
            BLACKNESS = 0x00000042, /* dest = BLACK*/
            WHITENESS = 0x00FF0062, /* dest = WHITE*/
        }

        [DllImport("Ws2_32.dll")]
        public static extern uint inet_addr(string ip);

        [DllImport("gdi32.dll", EntryPoint = "StretchDIBits")]
        public static extern int StretchDIBits([In] IntPtr hdc,
            int xDest, int yDest, int DestWidth, int DestHeight,
            int xSrc, int ySrc, int SrcWidth, int SrcHeight,
            [In] IntPtr lpBits, [In] IntPtr lpbmi, uint iUsage, uint rop);

        [DllImport("gdi32.dll", EntryPoint = "SetStretchBltMode")]
        public static extern int SetStretchBltMode(IntPtr hdc, StretchMode nStretchMode);
    }
    #endregion

}
